home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _CLRUPDA.C < prev    next >
Text File  |  1992-11-21  |  5KB  |  157 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define        CURSES_LIBRARY  1
  5. #include <curses.h>
  6.  
  7. #ifndef        NDEBUG
  8. char *rcsid__clrupda = "$Header: c:/curses/private/RCS/_clrupda.c%v 2.0 1992/11/15 03:24:28 MH Rel $";
  9. #endif
  10.  
  11.  
  12.  
  13.  
  14. /*man-start*********************************************************************
  15.  
  16.   PDC_clr_update()     - Updates the screen with a full redraw.
  17.  
  18.   PDCurses Description:
  19.        Updates the screen by clearing it and then redraw it in its
  20.        entirety. If _cursvar.refrbrk is TRUE, and there is pending
  21.        input characters, the update will be prematurely terminated.
  22.  
  23.   PDCurses Return Value:
  24.        This routine returns ERR if it is unable to accomplish it's task.
  25.        This return value is ONLY under FLEXOS.
  26.  
  27.        The return value OK is returned if there were no errors.
  28.  
  29.   PDCurses Errors:
  30.        No errors are defined for this function.
  31.  
  32.   Portability:
  33.        PDCurses        int PDC_clr_update( WINDOW* s );
  34.  
  35. **man-end**********************************************************************/
  36.  
  37. int    PDC_clr_update(WINDOW *s)
  38. {
  39. register int   i;
  40. register int   j;
  41.        WINDOW* w;
  42.        chtype* ch;
  43.        bool rc;
  44. #ifdef FLEXOS
  45.        char    line[80];
  46.        char    attr[80];
  47.        FFRAME  sframe;
  48.        RECT    drect,
  49.                srect;
  50. #endif
  51.        extern unsigned char atrtab[MAX_ATRTAB];
  52.        chtype temp_line[256]; /* this should be enough for the maximum width of a screen. MH-920715 */
  53.        chtype chr;
  54.  
  55.        w = curscr;
  56.        if (w == (WINDOW *)NULL)
  57.                return( ERR );
  58.        if (_cursvar.full_redraw)
  59.                PDC_clr_scrn(s); /* clear physical screen */
  60.  
  61.        s->_clear = FALSE;
  62.        for (i = 0; i < LINES; i++)     /* update physical screen */
  63.        {
  64.                if (s != w)     /* copy s to curscr */
  65. #ifdef DOS
  66. #  if  SMALL || MEDIUM
  67.                        movedata(FP_SEG(s->_y[i]),
  68.                                FP_OFF(s->_y[i]),
  69.                                FP_SEG(w->_y[i]),
  70.                                FP_OFF(w->_y[i]),
  71.                                COLS * sizeof(chtype));
  72. #  else
  73.                        memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
  74. #  endif
  75. #endif
  76. #ifdef OS2
  77.                        memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));
  78. #endif
  79.  
  80.        ch = temp_line; /* now have ch pointing to area to contain real attributes. MH-920715 */
  81. #ifdef         DOS
  82. #  if  SMALL || MEDIUM
  83.                movedata(FP_SEG(s->_y[i]), FP_OFF(s->_y[i]),
  84.                        FP_SEG(ch), FP_OFF(ch),COLS * sizeof(chtype));
  85. #  else
  86.                memcpy(ch,s->_y[i],COLS*sizeof(chtype)); /* copy current line to temp_line. MH-920715 */
  87. #  endif
  88. #else
  89.                memcpy(ch,s->_y[i],COLS*sizeof(chtype)); /* copy current line to temp_line. MH-920715 */
  90. #endif
  91.                for (j=0;j<COLS;j++)          /* for each chtype in the line... */
  92.                   {
  93.                    chr = temp_line[j] & A_CHARTEXT;
  94.                    temp_line[j] = chtype_attr(temp_line[j]) | chr;
  95.                   }
  96.  
  97.                if (_cursvar.direct_video)
  98.                {
  99. #ifdef FLEXOS
  100.                        PDC_split_plane(w, &line[0], &attr[0], i, 0, i, COLS);
  101. /* need to translate attr[] array to real attributes before displaying it. MH-920715 */
  102.                        drect.r_row = i;
  103.                        drect.r_col = 0;
  104.                        drect.r_nrow = 1;
  105.                        drect.r_ncol = COLS;
  106.  
  107.                        sframe.fr_pl[0] = (UBYTE *) line;
  108.                        sframe.fr_pl[1] = (UBYTE *) attr;
  109.                        sframe.fr_nrow = 1;
  110.                        sframe.fr_ncol = COLS;
  111.                        sframe.fr_use = 0x03;
  112.  
  113.                        srect.r_col = 0;
  114.                        srect.r_row = 0;
  115.                        srect.r_nrow = 1;
  116.                        srect.r_ncol = COLS;
  117.  
  118.                        s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect,
  119.                                (far unsigned short *) &sframe,
  120.                                (far unsigned short *) &srect);
  121. #endif
  122. #ifdef DOS
  123. #  if  SMALL || MEDIUM || MSC
  124.                        movedata(FP_SEG(ch), FP_OFF(ch),
  125.                                _cursvar.video_seg,
  126.                                _cursvar.video_ofs + (i*COLS*sizeof(chtype)),
  127.                                (COLS * sizeof(chtype)));
  128. #  else
  129.                        memcpy(MK_FP(_cursvar.video_seg,
  130.                          _cursvar.video_ofs + (i * COLS * sizeof(chtype))),
  131.                               ch, (COLS * sizeof(chtype)));
  132. #  endif
  133. #endif
  134. #ifdef OS2
  135.                                VioWrtCellStr ((PCH)ch, (USHORT)(COLS * sizeof(chtype)), (USHORT)i, 0, 0);
  136. #endif
  137.                }
  138.                else
  139.                {
  140.                        for (j = 0; j < COLS; j++)
  141.                        {
  142.                                PDC_gotoxy(i, j);
  143.                                PDC_putc( (*ch & A_CHARTEXT), (*ch & A_ATTRIBUTES) >> 8 );
  144.                                ch++;
  145.                        }
  146.                }
  147. #if defined(MSC) && defined (DOS)
  148.                rc = typeahead(stdin);
  149.                if (_cursvar.refrbrk && rc)
  150. #else
  151.                if (_cursvar.refrbrk && typeahead(stdin))
  152. #endif
  153.                        return( OK );
  154.        }
  155.        return( OK );
  156. }
  157.